home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 265_01 / cugread.c < prev    next >
Text File  |  1990-02-13  |  768b  |  40 lines

  1. #include <stdio.h>
  2.  
  3. void        main(argc, argv)
  4. int        argc;
  5. char        *argv[];
  6. {
  7. short        h_magic;
  8. long        longfile;
  9. short        h_namesize;
  10. register short    i;
  11. char        h_name[1000];
  12. register char    *np;
  13. FILE        *fp;
  14.  
  15. if((fp = fopen(argv[1], "r")) == NULL)
  16.     {
  17.     perror(argv[1]);
  18.     exit(1);
  19.     }
  20. do
  21.     {
  22.     fscanf(fp, "%6o%*6o%*6o%*6o%*6o%*6o%*6o%*6o%*11lo%6o%11lo",
  23.           &h_magic, &h_namesize, &longfile);
  24.     np = h_name;
  25.     for(i = h_namesize ; i-- ; )
  26.         *np++ = fgetc(fp);
  27.     *np = '\0';
  28.     printf("Name %s (%d), File size %ld\n", h_name, h_namesize, longfile);
  29.     if(h_magic != 070707)
  30.         {
  31.         fprintf(stderr, "bad magic!\n");
  32.         break;
  33.         }
  34.     /*fseek(fp, longfile, 1l);*/
  35.     while(longfile--)
  36.         fgetc(fp);
  37.     }
  38. while(strcmp(h_name, "TRAILER!!!"));
  39. }
  40.